
export let config = {
  'base': 'map',
  'map': {
    'china': {name: '中国', path: ''},
    'world': {name: '世界', path: ''},
    'anhui': {name: '安徽', path: 'province'},
    'aomen': {name: '澳门', path: 'province'},
    'beijing': {name: '北京', path: 'province'},
    'chongqing': {name: '重庆', path: 'province'},
    'fujian': {name: '福建', path: 'province'},
    'gansu': {name: '甘肃', path: 'province'},
    'guangdong': {name: '广东', path: 'province'},
    'guangxi': {name: '广西', path: 'province'},
    'guizhou': {name: '贵州', path: 'province'},
    'hainan': {name: '海南', path: 'province'},
    'hebei': {name: '河北', path: 'province'},
    'henan': {name: '河南', path: 'province'},
    'hubei': {name: '湖北', path: 'province'},
    'hunan': {name: '湖南', path: 'province'},
    'jiangsu': {name: '江苏', path: 'province'},
    'jiangxi': {name: '江西', path: 'province'},
    'jilin': {name: '吉林', path: 'province'},
    'liaoning': {name: '辽宁', path: 'province'},
    'neimenggu': {name: '内蒙古', path: 'province'},
    'ningxia': {name: '宁夏', path: 'province'},
    'qinghai': {name: '青海', path: 'province'},
    'shandong': {name: '山东', path: 'province'},
    'shanghai': {name: '上海', path: 'province'},
    'shanxi': {name: '山西', path: 'province'},
    'shanxi1': {name: '陕西', path: 'province'},
    'sichuan': {name: '四川', path: 'province'},
    'taiwan': {name: '台湾', path: 'province'},
    'tianjin': {name: '天津', path: 'province'},
    'xianggang': {name: '香港', path: 'province'},
    'xinjiang': {name: '新疆', path: 'province'},
    'xizang': {name: '西藏', path: 'province'},
    'yunnan': {name: '云南', path: 'province'},
    'zhejiang': {name: '浙江', path: 'province'},
    'heilongjiang': {name: '黑龙江', path: 'province'}
  },
  getGeoFilePath: function (name) {
    // 未加容错判断
    let path = config.map[name].path === '' ? '' : config.map[name].path + '/';
    return config.base + '/json/' + path + name;
  }
};

// example
/*
    {
        '中国': {'path': 'map/china', 'name': 'china'},
        '河南': {'path': 'map/province/henan', 'name': 'henan'},
    }
 */
export function getMapCache () {
  return Object.keys(config.map).reduce((a, k) => {
    a[config.map[k].name] = {'path': config.getGeoFilePath(k), name: k};
    return a;
  }, {});
}

export default config;
